/*******************************************************************************
 * Copyright (c) 2007 University of Oslo.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     University of Oslo - initial API and implementation
 *******************************************************************************/

package com.cea.papyrus.diagram.sequence.sedi.model.util;

import static com.cea.papyrus.diagram.sequence.sedi.model.util.ModelUtil.getBodies;
import static com.cea.papyrus.diagram.sequence.sedi.model.util.ModelUtil.getLanguages;

import org.eclipse.uml2.uml.OpaqueExpression;

/**
 * Utility methods for OpaqueExpressions.
 * 
 * @author frankd@ifi.uio.no
 */
public class OpaqueExpressionUtil {
	
	public static final String DEFAULT_LANGUAGE = "Java";
	
	public static void addBody(OpaqueExpression expr, String body) {
		addBody(expr, body, DEFAULT_LANGUAGE);
	}
	public static void addBody(OpaqueExpression expr, String body, String language) {
		// The UML specification requires size(bodies) == size(languages)
		getBodies(expr).add(body);
		getLanguages(expr).add(language);
	}
	
	public static void removeBody(OpaqueExpression expr, int index) {
		getBodies(expr).remove(index);
		getLanguages(expr).remove(index);
	}
}
